/*
 * Copyright 2012 Marsrutai.lt
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *   http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package lt.marsrutai.mobile.android.model;

import lt.marsrutai.mobile.android.dao.Identifier;
import android.os.Parcel;
import android.os.Parcelable;

/**
 * Base bookmark class holding common attributes.
 * 
 * @author Justas
 */
public abstract class Bookmark extends Entity implements Parcelable {

    private String scopeFolder;
    private String scopeName;

    public Bookmark() {
    }

    public Bookmark(Parcel in) {
        super(in);
        scopeFolder = in.readString();
        scopeName = in.readString();
    }

    @Override
    public void writeToParcel(Parcel dest, int flags) {
        super.writeToParcel(dest, flags);
        dest.writeString(scopeFolder);
        dest.writeString(scopeName);
    }

    @Override
    public int describeContents() {
        return 0;
    }

    @Identifier
    public String getScopeFolder() {
        return scopeFolder;
    }

    public void setScopeFolder(String scopeFolder) {
        this.scopeFolder = scopeFolder;
    }

    public String getScopeName() {
        return scopeName;
    }

    public void setScopeName(String scopeName) {
        this.scopeName = scopeName;
    }

    @Override
    public int hashCode() {
        final int prime = 31;
        int result = super.hashCode();
        result = prime * result + ((scopeFolder == null) ? 0 : scopeFolder.hashCode());
        result = prime * result + ((scopeName == null) ? 0 : scopeName.hashCode());
        return result;
    }

    @Override
    public boolean equals(Object obj) {
        if (this == obj) {
            return true;
        }
        if (!super.equals(obj)) {
            return false;
        }
        if (getClass() != obj.getClass()) {
            return false;
        }
        Bookmark other = (Bookmark) obj;
        if (scopeFolder == null) {
            if (other.scopeFolder != null) {
                return false;
            }
        }
        else if (!scopeFolder.equals(other.scopeFolder)) {
            return false;
        }
        if (scopeName == null) {
            if (other.scopeName != null) {
                return false;
            }
        }
        else if (!scopeName.equals(other.scopeName)) {
            return false;
        }
        return true;
    }

}
